home *** CD-ROM | disk | FTP | other *** search
- Path: spectre.star.harc.edu!diana!jaewan
- From: jaewan@diana.harc.edu (Jaewan Kim - ASTRO)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ display ASCII file
- Date: 22 Jan 1996 22:46:39 GMT
- Organization: Houston
- Distribution: world
- Message-ID: <4e144f$82t@spectre.star.harc.edu>
- References: <4dtsed$309o@useneta1.news.prodigy.com>
- NNTP-Posting-Host: diana.tdl.harc.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- << operator in stream library buffers everything before a space, a tab,
- an eol... And advances after discarding the following whitespaces.
- To do what you want to do, you need to use getline, or get functions of
- istream class.
-
-
- Shane Morrell (WCME76A@prodigy.com) wrote:
- : I am dabbling in C++ (see code below) and need a little assistance with
- : reading an ASCII file using the stream functions. This works like the
- : dos TYPE command well, I want it to anyway. It does fine except it will
- : not recognize the 'whitespace' in the text file. When it is displayed,
- : everything is crammedtogetherlikethis. Arrrgh!
-
- : Shane // shane@prodigy.com
- : =========================================
-
- : #include<iostream.h>
- : #include<fstream.h>
-
- : void main(int argc,char* argv[]) {
- : if(argc<2){
- : cout << "\nFilename parameter needed!";
- : << endl;
- : }
- : else{
- : ifstream src(argv[1], ios::nocreate);
- : if(src) {
- : char c;
-
- : src >> c;
- : while(!src.eof()) {
- : cout << c;
- : src >> c;
- : }
- :
- : src.close();
- : }
- : else{ cout << argv[1]
- : << " does not exist"
- : << endl;
- : }
- : }
- : }
-
-
-